package com.xqianli.bigdata.flink.transform;

import com.xqianli.bigdata.flink.utils.SensorReading;
import org.apache.flink.client.program.StreamContextEnvironment;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.util.OutputTag;

public class MulTransform {
    public static void main(String[] args) {
        StreamExecutionEnvironment env = StreamContextEnvironment.getExecutionEnvironment();
        String inputPath = "data/sensor.txt";
        DataStream<String> dataStream = env.readTextFile(inputPath);

        DataStream<SensorReading> mapStream = dataStream.map(line -> {
            String[] fields = line.split(",");
            return new SensorReading(fields[0], new Long(fields[1]), new Double(fields[2]));
        });

        // 分流用split/side output
        OutputTag<SensorReading> high = new OutputTag<>("high");
        OutputTag<SensorReading> low = new OutputTag<>("low");


        // 合流用connect
    }
}
